<%= render 'common/notice' %>

<div class="panel-no-border panel-primary">
  <!-- Default panel contents -->
  <div class="panel-heading"><strong><%= @topic.title %></strong></div>
  <div class="panel-body intro">
    <div class="row gray-font-12">
      <div class="col-xs-12">
        <span>来自: <%= link_to @topic.user.name, user_home_path(@topic.user) %></span>
        <span class="mgl20">创建: <%= @topic.created_at.strftime("%Y-%m-%d") %></span>
        <span class="mgl20">标签:
          <%- @topic.tags.each do |tag| %>
            <%= link_to tag.name, tag_path(tag), class: "mgt10" %>
          <%- end %>
        </span>
      </div>

      <br/>
      <br/>
      <div class="col-xs-12 content"><%= simple_format @topic.intro %></div>

      <br />
      <br />
      <div class="col-xs-6 mgt10">
        <%- if current_user && current_user.follow_topics.include?(@topic) %>
            <span class="text-left"><%= link_to "取消关注", unfollow_topic_path(@topic), method: :PUT %></span>
        <%- else %>
            <span class="text-left"><%= link_to "关注", follow_topic_path(@topic), method: :PUT %></span>
        <% end %>
        <span class="text-left"><%= "#{@topic.followers.size}人已关注" %></span>
        <span class="text-left mgl20"><%= "共#{@articles.size}篇文章" %></span>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col-xs-12 mgt20">
        <%= link_to '最近文章',topic_path(@topic), :class=> 'color372' %>
    </div>
  </div>

  <%= render partial: 'articles/list_preview', locals:{ topic: @topic, articles: @articles} %>

</div>

